package com.example.mythealthapp

import android.content.ComponentName
import android.content.Intent
import android.content.ServiceConnection
import android.net.Uri
import android.os.Binder
import android.os.Bundle
import android.os.IBinder
import androidx.appcompat.app.AppCompatActivity
import com.example.mythealthapp.about.AboutActivity
import com.example.mythealthapp.food_grid.FoodGridActivity
import com.example.mythealthapp.food_list.InfoListActivity
import com.example.mythealthapp.me.MeActivity
import com.example.mythealthapp.users.User
import kotlinx.android.synthetic.main.activity_home_menu.*

class HomeMenuActivity : AppCompatActivity() {

    lateinit var userphone:String

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_home_menu)

        val fromIntent = intent


        userphone= fromIntent.getStringExtra("userphone").toString()

        val intent=Intent(this,MyService::class.java)
        startService(intent)

        home_btn5.setOnClickListener {
            val intent=Intent(this, MeActivity::class.java)
            intent.putExtra("userphone",userphone)
            startActivity(intent)
        }

        home_btn1.setOnClickListener {
            val intent=Intent(this,InfoListActivity::class.java)
            startActivity(intent)
        }

        home_btn1.setOnClickListener {
            val intent=Intent(this,InfoListActivity::class.java)
            startActivity(intent)
        }
        home_btn2.setOnClickListener {
            val intent=Intent(this,FoodGridActivity::class.java)
            startActivity(intent)
        }
        home_btn3.setOnClickListener {
            val intent=Intent(this, AboutActivity::class.java)
            startActivity(intent)
        }
        home_btn4.setOnClickListener {
//            val intent=Intent(this,MoreActivity::class.java)
//            startActivity(intent)
            val intent = Intent()
            intent.data = Uri.parse("https://baike.baidu.com/item/%E5%90%88%E7%90%86%E8%86%B3%E9%A3%9F/1817464") //Url 就是你要打开的网址
            intent.action = Intent.ACTION_VIEW
            this.startActivity(intent) //启动浏览器
        }

    }

    override fun onDestroy() {
        super.onDestroy()
        val intent=Intent(this,MyService::class.java)
        stopService(intent)
    }


}